﻿Imports System.Threading

Module MdlCommon
    Public UsuarioActual As UsuarioObj

    <System.STAThread()> _
  Public Sub Main()
        AddHandler Application.ThreadException, AddressOf Application_ThreadException
        DevExpress.UserSkins.OfficeSkins.Register()
        DevExpress.UserSkins.BonusSkins.Register()
        DevExpress.Skins.SkinManager.EnableFormSkins()
        DevExpress.XtraEditors.Controls.Localizer.Active = New EditorLocalizer()
        Application.EnableVisualStyles()
        FrmInicial.RecuperarSkin()
        SerialObj.Seed = My.Application.Info.ProductName

        Application.Run(New FrmLogin())
    End Sub

    Public Sub Application_ThreadException(ByVal sender As Object, ByVal e As ThreadExceptionEventArgs)

        Dim message = String.Format(My.Resources.ResMensajes.ErrorMensaje, e.Exception)
        DevExpress.XtraEditors.XtraMessageBox.Show(message, My.Resources.ResMensajes.ErrorMensajeTitulo, MessageBoxButtons.OK, MessageBoxIcon.Error)

    End Sub

    Public Function FormularioAbierto(ByVal FormularioText As String, ByVal FormularioInicial As DevExpress.XtraEditors.XtraForm) As Boolean
        For i As Integer = 0 To FormularioInicial.MdiChildren.Length - 1
            If FormularioText = FormularioInicial.MdiChildren(i).Text Then
                FormularioInicial.MdiChildren(i).BringToFront()
                Return True
            End If
        Next

        Return False
    End Function


End Module
